package com.woniu.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniu.entity.CreditChannel;
import com.woniu.service.CreditChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/credit/channel")
@Api("渠道管理")
public class CreditChannelController extends BaseController {
    @Autowired
    CreditChannelService creditChannelService;

    /**
     * @description: 查询渠道公司
     * @author 86136
     */
    @GetMapping("/listChannel")
    @ApiOperation("渠道详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyName", value = "公司名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "area", value = "所在区域", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "level", value = "级别", dataType = "String", dataTypeClass = String.class),

    })
    public TableDataInfo listChannel(CreditChannel creditChannel) {
        startPage();
        List<CreditChannel> list = creditChannelService.listChannel(creditChannel);
        return getDataTable(list);
    }

    @PutMapping("/updateStatus/{id}/{stat}")
    @ApiOperation("修改渠道状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "渠道表公司id", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "status", value = "状态", dataType = "String", dataTypeClass = String.class),


    })
    public AjaxResult updateStatus(@PathVariable("id") int id, @PathVariable("stat") String stat) {
        int rows = creditChannelService.updateStatus(id, stat);
        return toAjax(rows);
    }

    /**
     * 新增渠道商
     *
     * @param creditChannel
     * @return
     */
    @PostMapping("/addChannel")
    @ApiOperation("新增渠道")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "渠道表公司id", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "companyName", value = "公司名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "tradeType", value = "行业类型", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "area", value = "所在区域", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "postalCode", value = "邮编", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "transactionPerson", value = "渠道业务联系人", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "position", value = "职位", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "transactionPhone", value = "业务联系人手机号码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "address", value = "详细地址", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "manageDomain", value = "管理后台域名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "logo", value = "公司logo", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "companyPhone", value = "公司电话", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "qqNumber", value = "QQ号码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "email", value = "邮箱", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "fax", value = "fax", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "url", value = "网址", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "companyIntroduction", value = "公司介绍", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "dutyParagraph", value = "税号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "invoiceHeader", value = "发票抬头", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankDeposit", value = "开户银行", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankAccount", value = "银行账号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "signingTime", value = "合作签约时间", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "level", value = "级别", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "status", value = "状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "enCode", value = "合作编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "note", value = "备注", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "ourTransactionPerson", value = "本公司业务练习人员", dataType = "String", dataTypeClass = String.class),


    })
    public AjaxResult addChannel(@RequestBody CreditChannel creditChannel) {
        return toAjax(creditChannelService.addChannel(creditChannel));
    }


    /**
     * 修改渠道商
     *
     * @param creditChannel
     * @return
     */
    @PutMapping("/updateChannel")
    @ApiOperation("修改渠道")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "渠道表公司id", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "companyName", value = "公司名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "tradeType", value = "行业类型", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "area", value = "所在区域", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "postalCode", value = "邮编", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "transactionPerson", value = "渠道业务联系人", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "position", value = "职位", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "transactionPhone", value = "业务联系人手机号码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "address", value = "详细地址", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "manageDomain", value = "管理后台域名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "logo", value = "公司logo", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "companyPhone", value = "公司电话", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "qqNumber", value = "QQ号码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "email", value = "邮箱", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "fax", value = "fax", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "url", value = "网址", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "companyIntroduction", value = "公司介绍", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "dutyParagraph", value = "税号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "invoiceHeader", value = "发票抬头", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankDeposit", value = "开户银行", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "bankAccount", value = "银行账号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "signingTime", value = "合作签约时间", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "level", value = "级别", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "status", value = "状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "enCode", value = "合作编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "note", value = "备注", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "ourTransactionPerson", value = "本公司业务练习人员", dataType = "String", dataTypeClass = String.class),


    })
    public AjaxResult updateChannel(@RequestBody CreditChannel creditChannel) {
        return toAjax(creditChannelService.updateChannel(creditChannel));
    }

    @GetMapping("/findById/{id}")
    @ApiOperation("根据id查询渠道")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "渠道表公司id", dataType = "int", dataTypeClass = Integer.class),


    })
    public AjaxResult findById(@PathVariable("id") int id) {
        CreditChannel creditChannel = creditChannelService.findById(id);
        return AjaxResult.success(creditChannel);
    }

}
